<script>
$(function() {
	$( "#tabs" ).tabs({
	    select: function(event, ui) {
	        var url = $.data(ui.tab, 'load.tabs');
	        if( url ) {
	            location.href = url;
	            return false;
	        }
	        return true;
	    },
	selected: 0
	});
});
</script>
<div id="tabs">
	<ul>
    <li><a href='#phanloaisv'>Phân loại đoàn viên</a> </li>
    <li><?php echo $this->Html->link(__('Xét đoàn viên ưu tú', true), array('controller'=>'dvutsvs','action' => 'viewdvut')); ?></li>
    </ul>
<div class="phanloaisvs index" id="phanloaisv">
<h2><?php __('Phân loại đoàn viên học kỳ '.$hockyht['Hocky']['tenhocky']);?></h2>
<h2><?php __('Chi đoàn: '.$user['Z1user']['tenchidoan']);?></h2>
    <?php 
        if(count($phanloaisinhviens)>0){
            echo "Xuất sắc: ".$tlxs.'%';
            echo "Khá: ".$tlk.'%';
            echo "Trung bình: ".$tltb.'%';
            echo "Yếu: ".$tly.'%';
            if(date('Y-m-d')>=$thoigian['Thoigianchophep']['moc1']&&date('Y-m-d')<=$thoigian['Thoigianchophep']['moc2']){
                echo $this->Form->create('Loaicdsinhvien',array('action'=>'update'));
                echo $this->Form->input('xeploaicd_id',array('type'=>'select','label'=>'Xếp loại chi đoàn','options'=>$loaicdsinhvien,'default'=>$loaicd));
                echo $this->Form->end('Sửa');
            }else echo $this->Form->input('xeploaicd_id',array('type'=>'select','label'=>'Xếp loại chi đoàn','options'=>$loaicdsinhvien,'default'=>$loaicd,'disabled'=>true));
        }else {
            echo "Chưa phân loại sinh viên!";
        }
        
    ?>
<?php echo $form->create('Phanloaisinhvien',array('action'=>'capnhat'));?>	
	<table cellpadding="0" cellspacing="0" id="tables">
    <tr>
            <th><?php  __('STT');?></th>
			<th><?php  __('Xếp loại');?></th>
			<th><?php __('MSSV');?></th>
			<th><?php __('Họ Tên');?></th>
            <th><?php __('Điểm RL');?></th>
            <th><?php __('Điểm TBHK');?></th>
            <th><?php //__('Số phong trào sinh viên');?></th>
            <th><?php //__('Số phong trào khoa');?></th>
            <th><?php __('Trạng thái');?></th>
            <th><?php __('Ghi chú');?></th>
			<th class="actions"><?php __('Actions');?></th>
	</tr>
	<?php
	$i = 0;
    $j=1;    
    //pr($phanloaisinhviens);
	foreach ($phanloaisinhviens as $phanloaisinhvien):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
        <td>
			<?php 
                echo $i;
                echo $form->input('sinhvien_id'.$j,array('label'=>'','readonly'=>true,'type'=>'hidden','value'=>$phanloaisinhvien['Z1phanloaisinhvien']['sinhvien_id'])); 
            ?>
		</td>    
		<td>
            <?php 
                if((date('Y-m-d')>=$thoigian['Thoigianchophep']['moc1']&&date('Y-m-d')<=$thoigian['Thoigianchophep']['moc2'])||$phanloaisinhvien['Z1phanloaisinhvien']['chinhsua']==1):
            ?>
			<?php echo $form->input('xeploai_id'.$j,array('type'=>'select','label'=>'','options'=>$xeploais,'default'=>$phanloaisinhvien['Z1phanloaisinhvien']['xeploai_id'])); ?>
            <?php else:?>
            <?php echo $phanloaisinhvien['Xeploai']['tenloai'];?>
            <?php endif;?>
		</td>
        <td><?php echo $phanloaisinhvien['Z1phanloaisinhvien']['mssv']; ?></td>
        <td><?php echo $phanloaisinhvien['Z1phanloaisinhvien']['hoten']; ?></td>
		<td><?php echo $phanloaisinhvien['Z1phanloaisinhvien']['diemrenluyen']; ?>&nbsp;</td>
		<td><?php echo $phanloaisinhvien['Z1phanloaisinhvien']['diemtbhk']; ?>&nbsp;</td>
        <td><?php //echo $this->Html->link(__($phanloaisinhvien['Z1phanloaisinhvien']['slcd'], true), array('controller'=>'thanhtichsvs','action' => 'viewtt', $phanloaisinhvien['Z1phanloaisinhvien']['mssv'])); ?>&nbsp;</td>
        <td><?php //echo $this->Html->link(__($phanloaisinhvien['Z1phanloaisinhvien']['slkhoa'], true), array('controller'=>'thanhtichkhoasvs','action' => 'viewtt', $phanloaisinhvien['Z1phanloaisinhvien']['mssv'])); ?>&nbsp;</td>
        <td><?php if($phanloaisinhvien['Z1phanloaisinhvien']['duyet']==1)echo "Đã duyệt"; else echo "Chưa duyệt"; ?>&nbsp;</td>
        <td><?php echo $phanloaisinhvien['Z1phanloaisinhvien']['ghichu']; ?>&nbsp;</td>
		<td class="actions">        
			<?php echo $this->Html->link(__('View', true), array('action' => 'view', $phanloaisinhvien['Z1phanloaisinhvien']['sinhvien_id'])); ?>
			<?php echo $this->Html->link(__('Edit', true), array('action' => 'edit', $phanloaisinhvien['Z1phanloaisinhvien']['sinhvien_id'])); ?>
			<?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $phanloaisinhvien['Z1phanloaisinhvien']['sinhvien_id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $phanloaisinhvien['Z1phanloaisinhvien']['sinhvien_id'])); ?>
		</td>
	</tr>
    <?php $j++;?>
<?php endforeach; ?>
	</table>
    <?php echo $form->submit('Cập nhật');?>    
    <?php echo $form->end();?>
    <?php echo $this->Html->link(__('Import bảng điểm rèn luyện & trung bình học kỳ', true), array('controller'=>'imports','action' => 'upload')); ?><br />
</div>
</div>